package come.bjpowernode.javase.threadsafe3;

public class AccountThread extends Thread {
    //两个线程必须共享同一个账户
    public Account act;

    //通过构造方法传递过来账户对象
    public AccountThread(Account act){
        this.act = act;
    }

    public void run(){
        //run方法
        //假设取款5000
        double money = 5000;
        //取款
        act.withdraw(money);
        System.out.println(Thread.currentThread().getName()+
                "对账户："+act.getActno() + "取款成功！取款金额为："
                + money + "账号余额为："+act.getBalance());
    }

}
